package com.masterclient.app.modules.shop.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil2;
import com.masterclient.app.modules.shop.beans.StockChangeBean;
import io.reactivex.functions.Consumer;

/**
 * @auther hjian
 * @date 2020/9/11.
 */
public class StockChangePresenter extends StockChangeContract.Presenter {

    @Override
    public void getStockChange(String productId,String spec,String change_type,String stock_type,String time_type,String time_start,String time_end,String page) {
        mRxManager.add(toSubscribe(RetrofitUtil2.getInstance().getStockChange(productId,spec,change_type,stock_type,time_type,
                time_start,time_end,page,"20"), (Consumer<CommonBaseResponse<StockChangeBean>>) bean -> {
            if(bean.getCode() == 0){
                mView.showData(bean.getData());
            }else {
                mView.showDataFailed(bean.getMsg());
            }
        },new ThrowableConsumer() {
            @Override
            public void accept(Throwable o) throws Exception {
                mView.showDataFailed("网络异常，请重试");
                super.accept(o);
            }
        }));
    }
}
